package org.jks.model;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

import com.google.gson.annotations.Expose;

@Entity
@Table(name = "Work")
public class Work {
	@Id
	@GeneratedValue(generator = "increment")
	@GenericGenerator(name = "increment", strategy = "increment")
	@Expose
	private long Id;
	@Column(length = 64, nullable = false, unique = true)
	@Expose
	private String Name;
	@Temporal(TemporalType.TIMESTAMP)
	@Expose
	private Date Worktime;
	@ManyToOne
	@JoinColumn(name = "Worktype", referencedColumnName = "Id", nullable = false)
	@Expose
	private WorkType Worktype;
	@ManyToOne
	@JoinColumn(name = "Worker", referencedColumnName = "Id", nullable = false)
	@Expose
	private User Worker;
	@Temporal(TemporalType.TIMESTAMP)
	@Expose
	private Date EndTime;
	@OneToOne(cascade = { CascadeType.ALL }, orphanRemoval = true)
	@JoinColumn(name = "DeviceRecipient", referencedColumnName = "Id", nullable = false)
	@Expose
	private DeviceRecipient DeviceRecipient;  //领用的所有设备信息
	@Expose
	private int State; // 状态:0:未开始，1：正在作业，2：完成
	@OneToMany(mappedBy = "Work", fetch = FetchType.LAZY, cascade = { CascadeType.ALL }, orphanRemoval = true)
	@Expose
	private List<Device> Devices;
	@Expose
	private long OutCount;//已出库的个数
	

	public long getOutCount() {
		return OutCount;
	}

	public void setOutCount(long outCount) {
		OutCount = outCount;
	}
	public long getId() {
		return Id;
	}

	public void setId(long id) {
		Id = id;
	}

	public String getName() {
		return Name;
	}

	public void setName(String name) {
		Name = name;
	}

	public Date getWorktime() {
		return Worktime;
	}

	public void setWorktime(Date worktime) {
		Worktime = worktime;
	}

	public WorkType getWorktype() {
		return Worktype;
	}

	public void setWorktype(WorkType worktype) {
		Worktype = worktype;
	}

	public User getWorker() {
		return Worker;
	}

	public void setWorker(User worker) {
		Worker = worker;
	}

	public Date getEndTime() {
		return EndTime;
	}

	public void setEndTime(Date endTime) {
		EndTime = endTime;
	}

	public DeviceRecipient getDeviceRecipient() {
		return DeviceRecipient;
	}

	public void setDeviceRecipient(DeviceRecipient deviceRecipient) {
		DeviceRecipient = deviceRecipient;
	}

	public int getState() {
		return State;
	}

	public void setState(int state) {
		State = state;
	}

	public List<Device> getDevices() {
		return Devices;
	}

	public void setDevices(List<Device> devices) {
		Devices = devices;
	}

}
